$OpenBSD: patch-scripts_buildversion_py,v 1.1 2017/03/23 23:31:51 sthen Exp $

fixup "clean version" strings for packaging; it only allows this if there's
a consistent version number detected for all binutils tools, however this
detection is too simplistic to cope with older binutils (mix of
"GNU assembler 2.17" and "GNU ld version 2.17" etc).

--- scripts/buildversion.py.orig	Thu Mar 23 23:16:58 2017
+++ scripts/buildversion.py	Thu Mar 23 23:22:58 2017
@@ -4,7 +4,7 @@
 # Copyright (C) 2015  Kevin O'Connor <kevin@koconnor.net>
 #
 # This file may be distributed under the terms of the GNU GPLv3 license.
-import sys, os, subprocess, shlex, time, socket, optparse, logging, traceback
+import sys, os, subprocess, shlex, time, socket, optparse, logging, traceback, re
 
 VERSION_FORMAT = """
 /* DO NOT EDIT!  This is an autogenerated file.  See scripts/buildversion.py. */
@@ -74,6 +74,8 @@ def tool_versions(tools):
         verstr = check_output("%s --version" % (tool,)).split('\n')[0]
         # Check if this tool looks like a binutils program
         isbinutils = 0
+        if verstr.startswith('GNU ld version'):
+            verstr = re.sub('ld version', 'version', verstr)
         if verstr.startswith('GNU '):
             isbinutils = 1
             verstr = verstr[4:]
